import { request } from "@/utils/request";
import type {
  DeleteParams,
  TagParams,
  QueryParams,
  QueryResult,
} from "./typing";
import type { PageResult, ResponseBody } from "@/api/typing";

/**新增标签 */
export const add = (params: TagParams) => {
  return request.post<TagParams, ResponseBody>("/answer/tag/add", params);
};

/**修改标签 */
export const update = (params: TagParams) => {
  return request.put<TagParams, ResponseBody>("/answer/tag/update", params);
};

/**分页查询标签 */
export const queryByPage = (params: QueryParams) => {
  return request.get<QueryParams, ResponseBody<PageResult<QueryResult>>>(
    "/answer/tag/page",
    { params }
  );
};

/**删除标签 */
export const del = (params: DeleteParams) => {
  return request.delete<DeleteParams, ResponseBody>("/answer/tag/delete", {
    params,
  });
};

/**根据学科编码列表查询标签参数 */
export interface SubjectParams {
  /**学科编码 */
  tagSubject: string;
}
/**根绝学科编码列表查询标签 */
export const queryListBySubject = (params: SubjectParams) => {
  return request.get<SubjectParams, ResponseBody>("/answer/tag/subject", {
    params,
  });
};
